package QRCode.study.Controller;

import QRCode.study.Utils.QRCodeUtil;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;

/**
 * 描述:
 *
 * @author Ychiha
 * @version 1.0
 * @date 15/1/2022 下午3:25
 */
@RestController
public class QrcodeController {

    /**
     * 生成二维码
     */
    @GetMapping("/product")
    public ModelAndView productcode() {
        String filename =
                //有logo
//        QRCodeUtil.zxingCodeCreate("http://localhost:8080/ok.html", "D:/QRCode/",500,"D:\\QRCode\\logo.jpg");
                //无logo
        QRCodeUtil.zxingCodeCreate("允许放行", "D:/QRCode/",500,null);

        ModelAndView mv = new ModelAndView();
        mv.setViewName("/qrcode/"+filename);
        return mv;
    }


    /**
     * 解析二维码
     */
    @GetMapping("/analysis")
    public void analysisCode() throws Exception {
        String result = QRCodeUtil.zxingCodeAnalyze("D:/QRCode/51.jpg");
        System.err.println("二维码解析内容："+result);
    }

}
